package com.xiaoshuidi.cloud.module.finance.controller.admin.invoice;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.module.finance.controller.admin.collection.vo.FinanceCollectionConfigReqVO;
import com.xiaoshuidi.cloud.module.finance.controller.admin.collection.vo.FinanceCollectionConfigRespVO;
import com.xiaoshuidi.cloud.module.finance.controller.admin.invoice.vo.FinanceInvoiceTitleConfigReqVO;
import com.xiaoshuidi.cloud.module.finance.controller.admin.invoice.vo.FinanceInvoiceTitleConfigRespVO;
import com.xiaoshuidi.cloud.module.finance.service.collection.FinanceCollectionConfigService;
import com.xiaoshuidi.cloud.module.finance.service.invoice.FinanceInvoiceTitleConfigService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;
import javax.validation.Valid;

@Tag(name = "运营配置 - 发票抬头配置")
@RestController
@RequestMapping("/finance/invoiceTitle")
@Validated
public class FinanceInvoiceTitleConfigController {
    @Resource
    private FinanceInvoiceTitleConfigService financeInvoiceTitleConfigService;

    @GetMapping("/get")
    @PermitAll
    @Operation(summary = "根据门店获取发票配置")
    public CommonResult<FinanceInvoiceTitleConfigRespVO> get(@RequestParam("apartmentId") Long apartmentId) {
        return CommonResult.success(financeInvoiceTitleConfigService.get(apartmentId));
    }


    @PostMapping("/save")
    @PermitAll
    @Operation(summary = "保存门店发票配置")
    public CommonResult<Boolean> save(@Valid @RequestBody FinanceInvoiceTitleConfigReqVO financeCollectionConfigReqVO) {
        financeInvoiceTitleConfigService.save(financeCollectionConfigReqVO);
        return CommonResult.success(true);
    }
}
